package pen_exam.xieceng_2023_11_20;

import codingforgreat.class05.Hash;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Class04_MoreZero {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] s = sc.nextLine().split(" ");
        int[] two = new int[n];
        int[] five = new int[n];
        int sumt = 0;
        int sumf = 0;
        for (int i = 0; i < n; i++) {
            int x = Integer.parseInt(s[i]);
            int t = 0;
            int f = 0;
            while (x % 2 == 0) {
                t++;
                x /= 2;
            }
            while (x % 5 == 0) {
                f++;
                x /= 5;
            }
            two[i] = t;
            five[i] = f;
            sumt += t;
            sumf += f;
        }
        int[][][] map = new int[n + 2][sumt + 1][sumf + 1];
        System.out.println(process(two, five, 0, 0, 0, map));
    }
    public static int process(int[] two, int[] five, int index, int t, int f,
                              int[][][] map) {
        if (map[index][t][f] != 0) {
            return map[index][t][f];
        }
        if (index >= two.length) {
            //todo 收集path 计算所有0
            map[index][t][f] = Math.min(t, f);
            return Math.min(t, f);
        }
        int p1 = process(two, five, index + 1, t, f, map);
        int p2 = process(two, five, index + 2, t + two[index], f + five[index], map);
        map[index][t][f] = Math.max(p1, p2);
        return Math.max(p1, p2);
    }
//    public static int getAllZero(ArrayList<Integer> path){
//        int two = 0;
//        int five = 0;
//        for (int i = 0; i < path.size(); i++) {
//            int x = path.get(i);
//            while(x % 2 == 0){
//                two++;
//                x /= 2;
//            }
//            while(x% 5 == 0){
//                five++;
//                x/= 5;
//            }
//        }
//        return Math.min(two,five);
//    }

}
